'use strict';

angular.module("phonecatApp",[]);

// Write your Javascript code.
function Bird(name){
    this.name=name;
}

Bird.prototype.Greet=function(){
    return this.name;
}

var bird=new Bird("maque");
console.log(bird.Greet());



var phonecatApp=angular.module("phonecatApp");
function PhoneListController($scope){


}
phonecatApp.controller("PhoneListController",["$scope",PhoneListController]);



  var phonecatApp=angular.module("phonecatApp");
  phonecatApp.component("phoneList",{
    template:
        '<ul>' +
          '<li ng-repeat="phone in $ctrl.phones">' +
            '<span>{{phone.name}}</span>' +
            '<p>{{phone.snippet}}</p>' +
          '</li>' +
        '</ul>',
    controller: function PhoneListController() {
      this.phones = [
        {
          name: 'Nexus S',
          snippet: 'Fast just got faster with Nexus S.'
        }, {
          name: 'Motorola XOOM™ with Wi-Fi',
          snippet: 'The Next, Next Generation tablet.'
        }, {
          name: 'MOTOROLA XOOM™',
          snippet: 'The Next, Next Generation tablet.'
        }
      ];
    }
  });

  var phonecatApp=angular.module("phonecatApp");
  function PhoneListController($scope,$http) {
      $scope.phones = [
        {
          name: 'Nexus S',
          snippet: 'Fast just got faster with Nexus S.',
          age:3
        }, {
          name: 'Motorola XOOM™ with Wi-Fi',
          snippet: 'The Next, Next Generation tablet.',
          age:1
        }, {
          name: 'MOTOROLA XOOM™',
          snippet: 'The Next, Next Generation tablet.',
          age:2
        }
      ];

      $scope.orderProperty="age";
       $scope.data = {
        availableOptions: [
        {id: '1', name: 'Option A'},
        {id: '2', name: 'Option B'},
        {id: '3', name: 'Option C'}
        ],
      selectedOption: {id: '3', name: 'Option C'} //This sets the default value of the select in the ui
       };

       $scope.getPhones=function(){
          $http.get("/js/components/phone-list/phone.json").then(function(response){
            $scope.phones=response.data;
          });
       }
    }
  phonecatApp.component("phoneList1",{
    templateUrl:"/js/components/phone-list/phone-list1.template.html",
    controller: ["$scope","$http",PhoneListController]
  });
